package com.zzw.design.observer;

public class Reader1 implements WriterListener{

    private String name;
    
    public Reader1(String name) {
        super();
        this.name = name;
    }

    public String getName() {
        return name;
    }
    
    //���߿��Թ�עĳһλ���ߣ���ע�������Լ��ӵ����ߵļ������б���
    public void subscribe(String writerName){
        WriterManager.getInstance().getWriter(writerName).registerListener(this);
    }
    
    //���߿���ȡ����עĳһλ���ߣ�ȡ����ע�������Լ������ߵļ������б���ע��
    public void unsubscribe(String writerName){
        WriterManager.getInstance().getWriter(writerName).unregisterListener(this);
    }
    
    public void addNovel(WriterEvent writerEvent) {
        Writer1 writer = writerEvent.getWriter();
        System.out.println(name+"֪��" + writer.getName() + "���������顶" + writer.getLastNovel() + "������Ҫȥ����");
    }
}
